import React, { Component } from 'react';
import './index.css';

export default class Header extends Component {
  render() {
    return (
      <div className='myInput'>
        <input type='text' placeholder='请输入' onKeyDown={this.addTask} />
      </div>
    );
  }
  addTask = e => {
    if (e.keyCode === 13 && e.target.value) {
      this.props.addTodo({ id: Math.random(), taskName: e.target.value, done: false });
      e.target.value = '';
    }
  };
}
